package com.chenchao.collection.stream;

import java.util.ArrayList;
import java.util.stream.Stream;

/**
 * @encoding : UTF-8
 * @Time : 2020/12/5 10:04
 * @Author : Chen Chao
 * @File : javaSE.com.chenchao.collection.stream.Test08.java
 * @Software : IntelliJ IDEA
 * @since : 1.8
 */
public class Test08 {
    public static void main(String[] args) {
        ArrayList<Actor> maleActors = new ArrayList<>();
        maleActors.add(new Actor("周润发"));
        maleActors.add(new Actor("成龙"));
        maleActors.add(new Actor("古天乐"));
        maleActors.add(new Actor("周杰伦"));
        maleActors.add(new Actor("林志颖"));

        ArrayList<Actor> femaleActors = new ArrayList<>();
        femaleActors.add(new Actor("范冰冰"));
        femaleActors.add(new Actor("林心如"));
        femaleActors.add(new Actor("林青霞"));
        femaleActors.add(new Actor("张曼玉"));
        femaleActors.add(new Actor("柳岩"));

        /*需求:男演员只有名字为三个字的前三人，
        女演员要姓林的且不要第一个*/
        Stream<Actor> maleLimit = maleActors.stream().
                filter((s) -> s.getName().length() >=3).limit(3);
        Stream<Actor> femaleLimit = femaleActors.stream().
                filter((s) -> s.getName().startsWith("林")).skip(1);
        Stream.concat(maleLimit,femaleLimit).
                map(Actor::getName).forEach(System.out::println);
    }
}
class Actor{
    private  String name;

    public Actor() {
    }

    public Actor(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}